home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d3
/
rettig.arc
/
TRSOURCE.EXE
/
ROMBIOS.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-10-22
|
9KB
|
285 lines
; ROMBIOS.ASM
;
; by Ralph Davis
; modified by Rick Spence
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC ROMBIOS
EXTRN __TR_HTOI:FAR ; Library C function (hex-to-integer)
EXTRN __TR_ITOD:FAR ; Library C function (integer-to-double)
EXTRN __TR_DTOI:FAR ; Library C function (double-to-integer)
EXTRN __TR_HEXASM:FAR ; Produces hex string
PARMS_IN STRUC
BP_OLD DW ?
RET_ADDR DD ?
INT_NUM DW ?
IN_PARM DD ?
FLAG_PARM DD ?
PARMS_IN ENDS
;****************************************
ROMBIOS_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:ROMBIOS_TEXT
;----------------------------------------
ROMBIOS PROC FAR ; ROM BIOS interface
JMP SHORT GO
PCOUNT DW 0 ; Counts parameters passed
SAVE_COUNT DW 8 ; Saves count
THIS_PARM DB 4 DUP (?),0 ; Holds current parameter
ABS_DISK DB 0 ; INT 25H or 26H
PRE_INT_BP DW ? ; INT 25H and 26H destroy BP
; Register values passed
AX_IN DW ?
BX_IN DW ?
CX_IN DW ?
DX_IN DW ?
SI_IN DW ?
DI_IN DW ?
DS_IN DW ?
ES_IN DW ?
; Register return values
AX_OUT DW ?
BX_OUT DW ?
CX_OUT DW ?
DX_OUT DW ?
SI_OUT DW ?
DI_OUT DW ?
DS_OUT DW ?
ES_OUT DW ?
; Parameter pointer table
PARM1_PTR DW ?
DW ?
PARM2_PTR DW ?
DW ?
PARM3_PTR DW ?
DW ?
PARM4_PTR DW ?
DW ?
PARM5_PTR DW ?
DW ?
PARM6_PTR DW ?
DW ?
PARM7_PTR DW ?
DW ?
PARM8_PTR DW ?
DW ?
REG_AX DW PARM1 ; Jump table
REG_BX DW PARM2
REG_CX DW PARM3
REG_DX DW PARM4
REG_SI DW PARM5
REG_DI DW PARM6
REG_DS DW PARM7
REG_ES DW PARM8
GO: PUSH BP
MOV BP,SP
PUSH DS
PUSH ES
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
CLD
AND CS:ABS_DISK,0 ; Clear disk interrupt flag
XOR AX,AX
MOV CS:PCOUNT,AX ; Initialize parameter counter to 0
MOV CX,16 ; Initialize parameter pointer table
PUSH CS ; (all zeroes)
POP ES
MOV DI,OFFSET CS:PARM1_PTR
REP STOSW
MOV AX,[BP].INT_NUM
CMP AL,10H ; don't allow lower than INT 10H
JGE INT_OK
JMP ERROR_EXIT
INT_OK:
CMP AL,25H ; check for absolute disk interrupts
JNE IS_IT_26H
MOV CS:PRE_INT_BP,BP ; save BP--INT 25H destroys it
OR CS:ABS_DISK,0FFH ; set flag
JMP SHORT SET_INT
IS_IT_26H:
CMP AL,26H ; disk write?
JNE SET_INT
MOV CS:PRE_INT_BP,BP ; save BP--INT 26H destroys it
OR CS:ABS_DISK,0FFH ; set flag
SET_INT:
MOV CS:CALL_ROM[1],AL
LDS SI,[BP].IN_PARM
MOV DI,OFFSET CS:THIS_PARM
CALL CONV_PARM ; CONV_PARM adds 4 to SI
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL_ROM DB 0CDH,?
PUSHF
CMP CS:ABS_DISK,0FFH ; was it a disk interrupt?
JNE RET_REGS
POP BP ; if it was, we have to
; go get the flags,
; then push them for later
ADD SP,2 ; this discards pre-interrupt flags
PUSH BP ; this saves interrupt state flags
MOV BP,CS:PRE_INT_BP ; restore pre-int BP
RET_REGS:
MOV CS:ES_OUT,ES
MOV CS:DS_OUT,DS
MOV CS:DI_OUT,DI
MOV CS:SI_OUT,SI
MOV CS:DX_OUT,DX
MOV CS:CX_OUT,CX
MOV CS:BX_OUT,BX
MOV CS:AX_OUT,AX
MOV CX,CS:SAVE_COUNT
RET_PARM: MOV SI,CX
DEC SI
SHL SI,1
XOR AX,AX
PUSH AX
PUSH CS:[AX_OUT][SI]
CALL __TR_HEXASM
ADD SP,4
SHL SI,1
MOV ES,CS:[PARM1_PTR][SI+2] ; Destination string pointer
MOV DI,CS:[PARM1_PTR][SI]
MOV DS,DX ; Source string pointer
MOV SI,AX
PUSH CX
MOV CX,4
REP MOVSB
POP CX
LOOP RET_PARM
JMP SHORT EXIT
ERROR_EXIT:
STC ; DOS uses Carry flag for error signal
EXIT: LDS SI,[BP].FLAG_PARM
POPF
PUSHF
POP AX
MOV [SI],AX
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
POP ES
POP DS
POP BP
RET
ROMBIOS ENDP
;----------------------------------------------------
CONV_PARM PROC NEAR
MOV BX,CS:PCOUNT
PUSH BX
SHL BX,1
SHL BX,1
MOV CS:PARM1_PTR[BX],SI
MOV CS:PARM1_PTR[BX+2],DS
PUSH CX
MOV CX,4
; DS:SI points to instring--ES:DI points to THIS_PARM
REP MOVSB
SUB DI,4
PUSH DX
PUSH SI ; at this point, SI points to next parm
PUSH ES ; pass location
PUSH DI
CALL __TR_HTOI ; AX now holds integer value
POP DI
POP ES
POP SI
POP DX
POP CX
POP BX ; Retrieve PCOUNT
SHL BX,1 ; PCOUNT becomes offset into
; jump table
CALL CS:[REG_AX][BX]
RET
CONV_PARM ENDP
;--------------------------------------------
PARM1 PROC NEAR
MOV CS:AX_IN,AX
RET
PARM1 ENDP
;----------------------------------------------------
PARM2 PROC NEAR
MOV CS:BX_IN,AX
RET
PARM2 ENDP
;----------------------------------------------------
PARM3 PROC NEAR
MOV CS:CX_IN,AX
RET
PARM3 ENDP
;----------------------------------------------------
PARM4 PROC NEAR
MOV CS:DX_IN,AX
RET
PARM4 ENDP
;----------------------------------------------------
PARM5 PROC NEAR
MOV CS:SI_IN,AX
RET
PARM5 ENDP
;----------------------------------------------------
PARM6 PROC NEAR
MOV CS:DI_IN,AX
RET
PARM6 ENDP
;----------------------------------------------------
PARM7 PROC NEAR
MOV CS:DS_IN,AX
RET
PARM7 ENDP
;----------------------------------------------------
PARM8 PROC NEAR
MOV BX,CS:BX_IN
MOV CX,CS:CX_IN
MOV DX,CS:DX_IN
MOV SI,CS:SI_IN
MOV DI,CS:DI_IN
CMP CS:DS_IN,0
JE PARM8_ES
PARM8_DS: MOV DS,CS:DS_IN
PARM8_ES: CMP AX,0
JE PARM8_RET
MOV ES,AX
PARM8_RET: MOV AX,AX_IN
RET
PARM8 ENDP
;----------------------------------------------------
ROMBIOS_TEXT ENDS
;****************************************************
END